<template>
  <div class="map-contant">
    <slot></slot>
  </div>
</template>
<script>
// -------------- 初始化 -------------------
import InitMapMixin from "../../components/AMap/mixins/initmap"
// -------------- AMap ----------------------
import DistricExplorer from "../../components/AMap/DistricExplorer/mixin/DistricExplorer";
import {addDEForHeat} from "../../components/AMap/DistricExplorer/index";
import {addMengBan} from "../../components/AMap/DistrictLayer";
import {addHeatMap, setHeatData} from "../../components/AMap/heatMap/initHeatMap";
// --------------- ws -----------------------
import wsMixin from "../../components/websocket/wsMixin";

export default {
  mixins: [InitMapMixin, wsMixin, DistricExplorer],
  mounted() {
    // addDEForHeat(this.mapInfo.adcode, this.map, this, 11);
    addMengBan(this.map, this.mapInfo.adcode)
    this.socketInit(this.$wsUrlBlackBoard, this.onMessage);
    addHeatMap(this.map)
    // this.map.setRotation(65)
  },
  data() {
    return {
      heatData: [],
      p: undefined
    }
  },
  methods: {
    addDEfunction() {

    },
    //   ------------- ws ---------------
    /**
     * 接收消息后
     * @param e
     */
    onMessage: function (e) {
      let message = JSON.parse(e.data);
      let heatmap = [];
      let scroll = [];
      let massmark = [];
      for (let i = 0; i < message.heatmap.length; i++) {
        if (message.heatmap[i].lng !== "x") {
          heatmap.push(message.heatmap[i]);
          scroll.push(message.scroll[i]);
          massmark.push(message.massmark[i]);
        }
      }
      setHeatData(heatmap);
      this.$emit("getScrollData", scroll);
      this.$emit("getBroadcastData", massmark);
    }
  }
};
</script>
<style scoped>
.map-contant {
  height: 100%;
  width: 100%;
}
</style>
